﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Business.IManager;
using System.Data;
using Entity;
using DataAccess.Service;
using DataAccess.IService;
using System.Collections;

namespace Business.Manager
{
    public class SearchManager : ISearchManager
    {
        ISearchService searchService = new SearchService();
        public DataSet searchTuition(String acaValue, String majValue, String graValue, String classValue, String yearValue)
        {
            if (acaValue.Equals("0"))
            {
                acaValue = "";
            }
            if (majValue.Equals("0"))
            {
                majValue = "";
            }
            if (graValue.Equals("0"))
            {
                graValue = "";
            }
            if (classValue.Equals("0"))
            {
                classValue = "";
            }
            if (yearValue.Equals("0"))
            {
                yearValue = "";
            }

            return searchService.getTuitionDataSet(acaValue, majValue, graValue, classValue, yearValue);
        }

        public DataSet searchTuitionDetail(String acaValue, String majValue, String graValue, String classValue, String yearValue)
        {
            if (acaValue.Equals("0"))
            {
                acaValue = "";
            }
            if (majValue.Equals("0"))
            {
                majValue = "";
            }
            if (graValue.Equals("0"))
            {
                graValue = "";
            }
            if (classValue.Equals("0"))
            {
                classValue = "";
            }
            if (yearValue.Equals("0"))
            {
                yearValue = "";
            }

            return searchService.getTuitionDetail(acaValue, majValue, graValue, classValue, yearValue);
        }

        public DataSet searchUtility(String uitilityYearValue, String uitilityMonthValue, String apartmentValue, String dorNumValue)
        {
            String utilityYearAndMonth = "";
            int switchYM = 0;

            if (uitilityYearValue.Equals("0") && uitilityMonthValue.Equals("0"))
            {
                switchYM = 0;   //年月都没选择
                utilityYearAndMonth = "";
            }
            else if (!uitilityYearValue.Equals("0") && uitilityMonthValue.Equals("0"))
            {
                switchYM = 1;   //年没选中月选中
                utilityYearAndMonth = uitilityYearValue;
            }
            else if (uitilityYearValue.Equals("0") && !uitilityMonthValue.Equals("0"))
            {
                switchYM = 2;   //年选中月没选中
                utilityYearAndMonth = uitilityMonthValue;
            }
            else
            {
                switchYM = 3;   //都选中
                utilityYearAndMonth = uitilityYearValue + uitilityMonthValue;
            }


            if (apartmentValue.Equals("0"))
            {
                apartmentValue = "";
            }

            try
            {
                Convert.ToInt32(dorNumValue.ToString());
                if (dorNumValue.Equals(""))
                {
                    dorNumValue = "";
                }
            }
            catch
            {
                dorNumValue = "";
            }


            
            return searchService.getUtility(utilityYearAndMonth, apartmentValue, dorNumValue,switchYM);


        }


    }
}
